log using "$Rep_smokelabor/2_analysis/output_logs/appendix_table5.log", replace 

	use "$Rep_smokelabor/1_build/regdata/county_quarter.dta", clear 
	
	* drop labor outcomes 
	drop *qwi* *lau* 
	
	* expand to industry groups 
	sort countyfip rfrnc_qtros
	gen _id = _n
	expand 5 
	bys _id: gen _industry=_n 
	gen industry="."
	local i = 0
	foreach val in 111 112 113 114 115 {
		local i = `i'+1
		replace industry="`val'" if _industry==`i'
	}
				
	tab industry 
	drop _id _industry
	destring industry, replace
	
	* merge agegrp-county-quarter qwi data 
	merge 1:1 countyfip rfrnc_yr rfrnc_qtroy industry using "$Rep_smokelabor/1_build/qwi/proc/qwi_naics3_ag_county_quarterly.dta", keep(match master) nogen
		
	* per million conversion
	gen pmil_qwi_emptotal = qwi_emptotal*1000000/seer_pop
	
	** separate effects by industry groups 
	egen g_industry=group(industry)
	
	local tbl_settings_log format(%6.3f) parentheses(stderr) asterisk()
	local tbl_settings_pmil format(%6.1f) parentheses(stderr) asterisk()
	local append replace
	
	forv grp =1/5 {
	preserve    
		local col=`grp'+1
		keep if g_industry==`grp'
		tsset fe_countyqtroy rfrnc_yr
		
		* first diff: y(t) minus y(t-1)
		foreach v of varlist pmil_qwi_emptotal {
			gen d_`v'=`v'-L1.`v'
		}
		
		* emp ols 
		ivreghdfe d_pmil_qwi_emptotal (pm25=hms_deep)  [aw=seer_pop] , a(fe_countyqtroy fe_styr) cluster(countyfip)
		summ pmil_qwi_emptotal [aw=seer_pop] if e(sample)
		local ymean `r(mean)'
		regsave using "$Rep_smokelabor/2_analysis/output_tables/appendix_table5.dta", addlabel(KleibergenPaap_F, `e(rkf)', outcome_mean, "`ymean'") table(col_`col', `tbl_settings_pmil') `append'
		local append append
						
	restore 	
	}
				
	use "$Rep_smokelabor/2_analysis/output_tables/appendix_table5.dta", replace
	drop if var == "r2"
	drop if var == "_id"
	drop if strpos(var, "_cons_") > 0
	ingap 3
	noisily list , sep(0)
	saveold "$Rep_smokelabor/2_analysis/output_tables/appendix_table5.dta", replace

log close



